<template>
	<view>
		<view class="account-content-view">
			<view class="title-hint">账户余额</view>
			<view class="amount-layout">
				<text class="amount-hint">￥</text>
				<text class="amount-money">{{parseInt(data.amount)/100.0}}</text>
			</view>
			<view class="hint" @click="share">满{{canWithdrawPrice.length?parseInt(canWithdrawPrice)/100.:0}}元即可提现，快继续推广吧 ></view>
			
			<view class="item-list">
				<view class="item util-font-regular">
					<view class="item-title">可提现金额</view>
					<view class="item-number">
						<view class="item-number-value util-font-medium">￥</view>
						<view class="item-number-unit">{{parseInt(data.amount)/100.0}}</view>
					</view>
			
				</view>
				<view class="item util-font-regular">
					<view class="item-title">已提现</view>
					<view class="item-number">
						<view class="item-number-value util-font-medium">￥</view>
						<view class="item-number-unit">{{parseInt(data.costAmount)/100.0}}</view>
					</view>
			
				</view>
				<view class="item util-font-regular">
					<view class="item-title">团队收益</view>
					<view class="item-number">
						<view class="item-number-value util-font-medium">￥</view>
						<view class="item-number-unit">{{parseInt(data.teamAccount)/100.0}}</view>
					</view>
			
				</view>
				<view class="item util-font-regular">
					<view class="item-title">累计收益</view>
					<view class="item-number">
						<view class="item-number-value util-font-medium">￥</view>
						<view class="item-number-unit">{{parseInt(data.totalAmount)/100.0}}</view>
					</view>
			
				</view>
			</view>
		</view>
		
		<!-- <view class="" style="background-color: #f5f5f5;width: 100%;height: 20rpx;"></view> -->

		<view class="orders-items" style="margin-top: 20rpx;" @click="commissionDetail">
			<view class="orders-title util-font-medium">佣金明细</view>
			<view class="orders-layout">
				<text>点击查看</text>
				<!-- <text>{{parseInt(data.todayAccount)/100.0}}</text> -->
				<image class="content-arrow-button" src="../../static/workbench/arrow_right.png" mode=""></image>
			</view>
		</view>
		<view class="orders-items" @click="commissionOrder">
			<view class="orders-title util-font-medium">已到账订单</view>
			<view class="orders-layout">
				<text>今日到账￥</text>
				<text>{{parseInt(data.todayAccount)/100.0}}</text>
				<!-- <image class="content-arrow-button" src="../../static/workbench/arrow_right.png" mode=""></image> -->
			</view>
		</view>

		<view class="orders-items" @click="commissionOrder">
			<view class="orders-title util-font-medium">待入账金额</view>
			<view class="orders-layout">
				<text>待入账￥</text>
				<text>{{parseInt(data.tbAccount)/100.0}}</text>
				<!-- <image class="content-arrow-button" src="../../static/workbench/arrow_right.png" mode=""></image> -->
			</view>
		</view>

		<view class="orders-items" @click="records">
			<view class="orders-title util-font-medium">提现明细</view>
			<view class="orders-layout">
				<text>提现中￥</text>
				<text>{{parseInt(data.withdrawAmount)/100.0}}</text>
				<image class="content-arrow-button" src="../../static/workbench/arrow_right.png" mode=""></image>
			</view>
		</view>

		<view class="footer-confirm-button util-font-medium" @click="withdraw">提现</view>
		<view class="wechat">
			<text>请添加客服微信(微信号：</text>
			<text style="color: #EB8735;" @click="serviceWechat">CAPTAIN__ONE</text>
			<text>)</text>
			<view>发送"我要提现"的口令，很快审核到账</view>
		</view>

	</view>
</template>

<script>
	// import uniPop
	export default {
		data() {
			return {
				data: {},
				canWithdrawPrice: '',
				
			}
		},
		onShow() {
			this.loadData()
			this.loadCanWithdrawPrice()
		},
		onPullDownRefresh() {
			this.loadData()
			this.loadCanWithdrawPrice()
		},
		methods: {
			loadData: function(){
				var that = this
				that.sendRequest({
					url: 'app/appBrokerageRecords/withdrawStatistics/' + uni.getStorageSync('userInfo').id,
					method: 'POST',
					header: that.$urlRequest.getHeader('token'),
					success: function(res){
						that.data = res.data.data
					}
				})
			},
			loadCanWithdrawPrice: function(){
				
				var that = this
				that.sendRequest({
					url: 'app/appDictionaries/withDrawCount',
					method: 'POST',
					header: that.$urlRequest.getHeader('token'),
					success: function(res){
						that.canWithdrawPrice = res.data.data.value
					}
				})
			},
			share: function() { //推广按钮逻辑
				uni.navigateTo({
					url: 'inviteFriends'
				})
			},
			withdraw: function() { //提现按钮逻辑
				var that = this;
				if (parseInt(that.data.amount) < parseInt(this.canWithdrawPrice)) {
					uni.showModal({
						content: '可提现金额不足￥'+parseInt(this.canWithdrawPrice)/100.0+'，当日结算不可提现哦~',
						showCancel: false,
						confirmText: '我知道了',
						confirmColor: '#E95918'
					});
					return
				}
				
				uni.navigateTo({
					url: 'withdraw'
				})
			},
			commissionDetail: function(){ // 佣金收入明细
				uni.navigateTo({
					url: 'commissionDetail'
				})
			},
			commissionOrder: function() { //提现金额列表
				// uni.navigateTo({
				// 	url: 'commissionOrder'
				// })
			},
			records: function() { //提现明细
				uni.navigateTo({
					url: 'withdrawalDetail'
				})
			},
			serviceWechat: function(){
				uni.showActionSheet({
					itemList: ['复制'],
					success(res) {
						if (res.tapIndex == 0) {
							uni.setClipboardData({
								data: 'CAPTAIN__ONE'
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}

	.account-content-view {
		background-color: #FFFFFF;
		padding: 80rpx 0 20rpx;
	}
	
	.title-hint {
		text-align: center;
		color: #666666;
		font-size: 26rpx;
	}

	.amount-layout {
		text-align: center;
		margin-top: 40upx;
	}

	.amount-hint {
		color: #E95918;
		font-size: 26rpx;
	}

	.amount-money {
		color: #E95918;
		font-size: 52upx;
	}

	.hint {
		text-align: center;
		margin-top: 30upx;
		color: #E95918;
		font-size: 26rpx;
	}


	.item-list {
		margin-top: 60rpx;
		display: flex;
		justify-content: space-between;
	}

	.item {
		width: 165rpx;
		text-align: center;
	}

	.item-title {
		width: 100%;
		height: 42rpx;
		line-height: 42rpx;
		font-size: 26rpx;
		color: #666666;
	}

	.item-number {
		width: 100%;
		height: 43rpx;
		line-height: 43rpx;
		margin-top: 10rpx;
	}

	.item-number-unit {
		color: #333333;
		font-size: 34rpx;
		display: inline-block;
	}

	.item-number-value {
		color: #333333;
		font-size: 24rpx;
		display: inline-block;
	}

	.orders-items {
		background-color: white;
		height: 120rpx;
		line-height: 120rpx;
		display: flex;
		padding: 0 30rpx;
		justify-content: space-between;
		border-bottom: 2rpx solid #f1f1f1;
	}

	.orders-title {
		color: #333333;
		font-size: 34rpx;
		display: inline-block;
	}

	.orders-layout {
		color: #666666;
		font-size: 34rpx;
		display: inline-block;
	}

	.footer-confirm-button {
		width: 600upx;
		height: 96upx;
		margin-top: 60upx;
		background: linear-gradient(to right, #eb8735, #ea5a2e);
		border-radius: 10upx;
		margin-left: 75upx;
		line-height: 96upx;
		text-align: center;
		color: #FFFFFF;
		font-size: 34upx;
	}

	.wechat {
		margin-top: 30upx;
		text-align: center;
		color: #999999;
		font-size: 26upx;
		margin-bottom: 50rpx;
	}
	.content-arrow-button {
		width: 30rpx;
		height: 30rpx;
		margin-top: 45rpx;
		float: right;
	}
</style>
